# Contributor: Leo <thinkabit.ukim@gmail.com>
# Maintainer: Rasmus Thomsen <oss@cogitri.dev>
pkgname=cbindgen
# Please be VERY careful bumping this - Firefox regularly fails to build
# with new versions!
pkgver=0.24.3
pkgrel=0
pkgdesc="Tool to generate C bindings from Rust code"
url="https://github.com/eqrion/cbindgen"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le" # Limited by cargo
license="MPL-2.0"
makedepends="cargo"
checkdepends="cython"
source="$pkgname-$pkgver.tar.gz::https://crates.io/api/v1/crates/cbindgen/$pkgver/download"
options=net

export CARGO_PROFILE_RELEASE_LTO="true"
export CARGO_PROFILE_RELEASE_PANIC="abort"
export CARGO_PROFILE_RELEASE_CODEGEN_UNITS=1
export CARGO_PROFILE_RELEASE_OPT_LEVEL="s"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --release --frozen
}

check() {
	# Failing tests
	rm -rf tests/rust/expand*
	cargo test --frozen
}

package() {
	install -Dm0755 target/release/cbindgen -t "$pkgdir"/usr/bin
}

sha512sums="
3a39be67a87aa7a4dd9baaf6b803215f4587bd7925c4315c5ec93954e021471919fa977ad2084f099c606daa392350de3557bba56cef77806def99c40318ef05  cbindgen-0.24.3.tar.gz
"
